﻿using System.IO;
using System.Collections.Generic;
using UnityEngine;
using Baidu.Aip.Face;

public class Testfacedetect : MonoBehaviour
{

    private Face client;
    private byte[] image;
    private Dictionary<string, object> options;

    private void Awake()
    {
        System.Net.ServicePointManager.ServerCertificateValidationCallback +=
            delegate (object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
            System.Security.Cryptography.X509Certificates.X509Chain chain,
            System.Net.Security.SslPolicyErrors sslPolicyErrors)
            {
                return true;
            };
        client = new Face("a7EY1wb5xIZ6csrH7xngGsiO", "91gcDeLgs4C7tG1dKOCPcH7dKUbFqqPi ");
        image = File.ReadAllBytes(Application.streamingAssetsPath + "/1.jpg");
        options = new Dictionary<string, object>()
        {
            {"face_fields", "beauty,age,expression,gender" }
        };
    }

    public void StartDetect()
    {
        var result = client.FaceDetect(image, options);
        //debugInfo.text = result.ToString();
        Debug.Log(result.ToString());
    }

    // Use this for initialization
    void Start()
    {
        StartDetect();

    }

    // Update is called once per frame
    void Update()
    {

    }
}
